package net.jxta.myjxta.ui.action;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import net.jxta.myjxta.View;
import net.jxta.myjxta.ui.ChatFrame;
import net.jxta.myjxta.ui.MyJXTAView;
import net.jxta.myjxta.util.Resources;

public class ChatFrameAction extends AbstractAction{
	private MyJXTAView view = null;
    private String name=null;

    public ChatFrameAction(String name, MyJXTAView view) {
        super(name);

        this.view = view;
        this.name=name;
    }
    
    public void actionPerformed(ActionEvent ae) {
    	if(!ChatFrame.isVisible){

    		
    		JPanel p = new JPanel();
            GridBagLayout gb = new GridBagLayout();
            GridBagConstraints gbc = new GridBagConstraints();

            p.setLayout(gb);


            gbc.gridx = 0;
            gbc.gridy = 0;
            gbc.gridwidth = GridBagConstraints.REMAINDER;
//            gbc.insets = new Insets(3, 3, 3, 3);
            gbc.anchor = GridBagConstraints.NORTHWEST;
            gbc.weightx = 1.0;
            gbc.weighty = 1.0;
            gbc.fill = GridBagConstraints.BOTH;

            gb.setConstraints(view.plugins, gbc);
            p.add(view.plugins);
    		  		
    		ChatFrame cf=new ChatFrame(p);
            cf.setVisible(true);
		}
    }
}
